package com.yuan.blog.core.utils;

import org.mindrot.jbcrypt.BCrypt;

public class PasswordUtils {

    // 加密
    public static String hashPw(String pw) {
        return BCrypt.hashpw(pw, BCrypt.gensalt());
    }

    // 比对
    public static boolean check(String pw, String dbPw) {
        return BCrypt.checkpw(pw, dbPw);
    }

    public static void main(String[] args) {
        String pwd = hashPw("123456");
        System.out.println(pwd);
        boolean check = PasswordUtils.check("123456", "$2a$10$pX7QUozM5Jt8RsnZilf4XeSrloy103cZG8T.CG/xV9cB/3vpOnE2e");
        System.out.println(check);
    }
}
